package rjeutsky.lab3;

import java.sql.SQLException;

import org.hibernate.SessionFactory;

import rjeutsky.database.jpa.JPAConnector;
import rjeutsky.database.jpa.JPARepository;

public class ApplicationController extends rjeutsky.ApplicationController {
	protected SessionFactory sessionFactory;
	
	//did not found how to get correct ServiceRegistry object
	@SuppressWarnings("deprecation")
	@Override
	protected void initializeRepository() throws SQLException {
		sessionFactory =  new JPAConnector().GetConfiguration().buildSessionFactory();
		repository = new JPARepository(sessionFactory);
	}
	
	@Override
	public void finishApplication() throws SQLException {
		sessionFactory.close();
	}
}
